package com.example.projectcode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.projectcode.mapper.AdministraterMapper;
import com.example.projectcode.model.Administrater;
import com.example.projectcode.model.Student;
import com.example.projectcode.service.AdministraterService;
import org.springframework.stereotype.Service;

@Service
public class AdministraterServiceImpl extends ServiceImpl<AdministraterMapper, Administrater> implements AdministraterService {
    @Override
    public boolean insertAdministrater(Administrater administrater) {

            return baseMapper.insert(administrater)>0;
    }

    @Override
    public int deleteAdministraterById(Integer id) {
        QueryWrapper<Administrater> administraterQueryWrapper = new QueryWrapper<>();
        administraterQueryWrapper.eq("ad_id",id);
        return baseMapper.delete(administraterQueryWrapper);

    }

    @Override
    public int updateStudent(Administrater administrater) {
        UpdateWrapper<Administrater> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("ad_id",administrater.getAdId());
        return  baseMapper.update(administrater,updateWrapper);

    }
}
